package com.library.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.library.service.BookService;
import com.library.service.impl.BookServiceImpl;
@WebServlet("/deleteBook.do")
public class DeleteBook extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		int bookId = Integer.parseInt(req.getParameter("bookId"));
		BookService bookService = new BookServiceImpl();
		int num = bookService.deleteBookByBookId(bookId);
		ObjectMapper om = new ObjectMapper();
		resp.setContentType("application/json;charset=UTF-8");
		String nums = om.writeValueAsString(num);
		resp.getWriter().write(nums);
	}
}
